<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

/************************************************* admin 模块路由配置 *************************************************/
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function () {
    Route::get('/', function() {
        return redirect('/admin/login');
    });

    # 退出
    Route::get('logout', 'LoginController@getLogout');

    # 登录
    Route::get('login', 'LoginController@getLogin');
    Route::post('login', 'LoginController@postLogin');

    # 需登录后可访问
    Route::group(['prefix' => '', 'middleware' => ['auth:admin']], function () {
        Route::get('index', 'IndexController@index');

        # 菜单管理
        Route::resource('menu', 'MenuController');
        Route::post('menus', 'MenuController@getMenus');

        # 用户管理
        Route::get('user', 'UsersController@getInfo');
        Route::put('user', 'UsersController@putInfo');
        Route::resource('users', 'UsersController');

        # 系统管理
        Route::get('setting', 'ConfigController@getConfig');
        Route::put('setting', 'ConfigController@putConfig');
        Route::resource('log', 'LogController');
    });
});


/************************************************* index 模块路由配置 *************************************************/
Route::group(['prefix' => '', 'namespace' => 'Index'], function () {
    // 首页
    Route::get('/', function () {
	    return view('index.index');
	});
});
